package com.dkm.ec.product.domain;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.biz.domain.AbstractDomain;
import com.dkm.biz.gl.persistence.entity.GlConfigPo;
import com.dkm.biz.gl.repository.GlConfigRepository;
import com.dkm.ec.product.persistence.dao.ProdTrackDao;
import com.dkm.ec.product.persistence.entity.ProdTrackPo;
import com.dkm.ec.product.service.ProdTrackService;

/**
 * 对象功能:产品浏览足迹 领域对象实体
 * 开发人员:Yuki
 * 创建时间:2014-12-31 13:36:54
 */
@Service
@Scope("prototype")
public class ProdTrack extends AbstractDomain<String, ProdTrackPo>{
	 
	 private ProdTrackDao prodTrackDao = null;

	 private GlConfigRepository glConfigRepository = null;
	 private ProdTrackService prodTrackService = null;


	protected void init(){
		prodTrackDao = SpringHelper.getBean(ProdTrackDao.class);
		glConfigRepository =SpringHelper.getBean(GlConfigRepository.class);
		prodTrackService = SpringHelper.getBean(ProdTrackService.class);
		setDao(prodTrackDao);
	}	 
	
	public Boolean saveTrack(List<ProdTrackPo> prodTrackPoList,Integer modCount){
	
		GlConfigPo glConfigPo = glConfigRepository.getByConfigKey("track_interval");
		if(glConfigPo!=null&&glConfigPo.getValue()!=null){
			Integer interval = Integer.parseInt(glConfigPo.getValue());
			if(interval<=modCount){
				//修改次数超过数据库的参数，则执行保存数据库操作
			//	prodTrackService.saveTrack(prodTrackPoList);
				return true;
			}
		}
		return false;

	}
	public Boolean saveTrackForce(List<ProdTrackPo> prodTrackPoList){
		if(prodTrackPoList==null || prodTrackPoList.size()==0){
			return false;
		}
		GlConfigPo glConfigPo = glConfigRepository.getByConfigKey("track_interval");
		if(glConfigPo!=null&&glConfigPo.getValue()!=null){
			Integer interval = Integer.parseInt(glConfigPo.getValue());
				//修改次数超过数据库的参数，则执行保存数据库操作
			//	prodTrackService.saveTrack(prodTrackPoList);
				return true;
			}
		return false;

	}
	 
}
